package com.ruoyi.yl.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.domain.CommentInfo;
import com.ruoyi.yl.service.ICommentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 评论接口
 *
 * @author ruoyi
 */
@Slf4j
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    ICommentInfoService commentInfoService;


    /*
     * 1. 添加评论信息
     * 2. 等待审核
     */

    @PostMapping("/submit")
    public AjaxResult saveOrderComment(@RequestBody CommentInfo commentInfo) {
        commentInfoService.saveOrderComment(commentInfo);
        return AjaxResult.success();
    }



    @GetMapping("/review/true")
    public R<AjaxResult>  reviewTrue(String orderNo) {
        log.info("reviewTrue： {}",orderNo);
        try {
            commentInfoService.reviewTrue(orderNo);
            return R.ok(AjaxResult.success());
        } catch (RuntimeException e) {
            log.error(e.getMessage());
            return R.ok(AjaxResult.error());
        }

    }



    @GetMapping("/review/false")
    public R<AjaxResult> reviewFalse( String orderNo,String reviewStatusDesc) {
        log.info("reviewFalse： {}",orderNo);
        try {
            commentInfoService.reviewFalse(orderNo,reviewStatusDesc);
            return R.ok(AjaxResult.success());
        } catch (RuntimeException e) {
            log.error(e.getMessage());
            return R.ok(AjaxResult.error());
        }
    }




}
